<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            padding: 0;
            margin:0;
        }
        #box{
            width:100vw;
            height:200px;
        }
        #price{
            width:100vw;
            height: 200px;
            background:orange;
            color:white;
            font-size: 40px;
            text-align: center;
            line-height: 200px;

        }
        #c{
            position: absolute;
            top:0;
            left:0;
        }
    </style>
</head>
<body>
    <div id="box">
        <div id="price"></div>
        <canvas id="c">浏览器不支持canvas</canvas>
    </div>
    <script>
        var c=document.getElementById("c");
        var ctx=c.getContext("2d");
        var w=window.innerWidth;//返回当前窗口文档显示区的宽度
        c.width=w;
        c.height=200;
        ctx.fillStyle="#ccc";
        ctx.fillRect(0,0,w,200);
        // touchstart 当手指触摸屏幕的时候触发
        // touchmove当手指在屏幕上滑动的时候连续触发
        c.ontouchstart=function(e){//事件对象
            console.log(e.touches[0].clientX+"*"+e.touches[0].clientY);//获取到第一个触点,横坐标和纵坐标
            var startX=e.touches[0].clientX;
            var startY=e.touches[0].clientY;
            ctx.beginPath();
            ctx.lineCap="round";//线的顶点样式
            ctx.lineJoin="round";//线条交接位置的样式
            ctx.lineWidth=30;//线宽

            ctx.globalCompositeOperation="destination-out";
            ctx.moveTo(startX,startY);
        };

        c.ontouchmove=function(e){//事件对象
            var moveX=e.touches[0].clientX;
            var moveY=e.touches[0].clientY;
            ctx.lineTo(moveX,moveY);
            ctx.stroke();

        };

        var arr=["包永强","王壮","好倩","大庆","大庆","大庆","大庆","大庆","大庆","大庆"];//0-9
        var price=document.getElementById("price");
        var num=parseInt(Math.random()*arr.length);//[0,10)
        price.innerHTML=arr[num];
    </script>
</body>
</html>